import axios from 'axios'

const ajax = axios.create({
  baseURL: '/api'
})

// 请求拦截
ajax.interceptors.request.use(config => {
  return config
})

// 响应拦截
ajax.interceptors.response.use(resp => {
  if (resp.status === 200) {
    if (resp.data.code === 200) {
      return resp.data.data
    }
  }
  return {
    code: 0,
    msg: '请求失败'
  }
})

export const getTabs = () => ajax.get('/tabs')
